using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using ProjectSurvivor;
using QFramework;
using UnityEngine;

public class CoinUpgradeSystem : AbstractSystem
{
    public static EasyEvent OnCoinUpgradeSystemChanged = new EasyEvent();
    public List<CoinUpgradeItem> Items { get; } = new List<CoinUpgradeItem>();
    public CoinUpgradeItem Add(CoinUpgradeItem item)
    {
        Items.Add(item);
        return item;
    }
    protected override void OnInit()
    {
        var coinPercentLv1 = Add(new CoinUpgradeItem()
          .WithKey("coin_percent_lv1")
          .WithDescription("金币掉落概率提升 Lv1")
          .WithPrice(5)
          .OnUpgrade((item) =>
          {
              Global.CoinPercent.Value += 0.1f;
              Global.Coin.Value -= item.Price;
          }));
        var coinPercentLv2 = Add(new CoinUpgradeItem()
         .WithKey("coin_percent_lv2")
         .WithDescription("金币掉落概率提升 Lv2")
         .WithPrice(7)
         .Condition((_) => coinPercentLv1.UpgradeFinish)
         .OnUpgrade((item) =>
         {
             Global.CoinPercent.Value += 0.1f;
             Global.Coin.Value -= item.Price;
         }));
        var coinPercentLv3 = Add(new CoinUpgradeItem()
       .WithKey("coin_percent_lv3")
       .WithDescription("金币掉落概率提升 Lv3")
       .WithPrice(10)
        .Condition((_) => coinPercentLv2.UpgradeFinish)
       .OnUpgrade((item) =>
       {
           Global.CoinPercent.Value += 0.1f;
           Global.Coin.Value -= item.Price;
       }));

        Items.Add(new CoinUpgradeItem()
        .WithKey("exp_percent")
        .WithDescription("经验值掉落概率提升")
        .WithPrice(5)
        .OnUpgrade((item) =>
        {
            Global.ExpPercent.Value += 0.1f;
            Global.Coin.Value -= item.Price;
        }));

        Items.Add(new CoinUpgradeItem()
        .WithKey("max_hp")
        .WithDescription("主角的最大血量+1")
        .WithPrice(30)
        .OnUpgrade((item) =>
        {
            Global.MaxHp.Value++;
            Global.Coin.Value -= item.Price;
        }));

        // BtnExpPercentUpgrade.onClick.AddListener(() =>
        //      {
        //          Global.ExpPercent.Value += 0.1f;
        //          Global.Coin.Value -= 5;
        //          AudioKit.PlaySound("ability_level_up");
        //      });

        // BtnPlayerMaxHpUpgrade.onClick.AddListener(() =>
        // {
        //     Global.MaxHp.Value++;
        //     Global.Coin.Value -= 30;
        //     AudioKit.PlaySound("ability_level_up");
        // });
    }
    public void Say()
    {
        //  UnityEngine.Debug.Log();
        "Hello CoinUpgradeSystem".LogInfo();
    }

}
